
import * as PIXI from 'pixi.js';
import clickSrc from 'common/asset/img/game/click.png';
import Rect from 'components/rect';
import Text from 'components/text';
import Image from 'components/image';
const { Container } = PIXI;

export default class ItemModal {
  constructor({parent, onGetItem, ...props}) {


    const {height, box, top, width} = props;
    this.onGetItem = onGetItem;
    this.parent = parent;
    this.container = new Container();

    if (box.src) {
      let img = new Image({src: box.src, top: 120});
      const scale = 250 / img.height;
      img.height = 250;
      img.width = img.width * scale;
      img.x = (width - img.width) / 2;
      this.container.addChild(img);
    }

    if (box.showSrc) {
      let img = new Image({src: box.showSrc, top: 120});
      const scale = 250 / img.height;
      img.height = 250;
      img.width = img.width * scale;
      img.x = (width - img.width) / 2;
      this.container.addChild(img);
    }

    if (box.getText) {
      let getText = new Text({value: box.getText, top: 410, fontSize: 34, fontWeight: 600});
      getText.x = (width - getText.width) / 2;
      this.container.addChild(getText);
    }

    if (box.useText) {
      let useText = new Text({value: box.useText, top: 460, fontSize: 28});
      useText.x = (width - useText.width) / 2;
      this.container.addChild(useText);


      if (box.key === 'sunBlock') {
        let noticeText = new Text({value: '防晒长达12.5小时,阳光诅咒终于破解啦,快\n离开海螺房吧～', top: 530, fontSize: 28, fill: 0xfc0300});
        noticeText.x = useText.x;
        this.container.addChild(noticeText);
      }
    }


    this.container.y = top;
    this.container.x = (window.CFG.view.width - width) / 2;


    let click = new Image({src: clickSrc, top: 750, width: 168, height: 130});
    click.x = (window.CFG.view.width - 168) / 2;
    this.container.addChild(click);
  }
}
